<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    留言：<input type="text" value="" id="inp" maxlength="15">
    <span class="shuzi">10/10</span>

</body>
<script>
    var inp = document.querySelector('input');
    var shu = document.querySelector('.shuzi')

    function text(field, countfield, maxlength) {
        if (field.value.length > maxlength) {
            field.value = field.value.substring(0, maxlength);
        } else {
            text.value = maxlength - field.value.length;
        }
    }
    text();
</script>

</html>